import requests
from conf import MessageConf


def message(*args, **kwargs):
    review_mobile = MessageConf.MOBILES.split(',')
    headers = {'Content-Type': 'application/json'}
    text = {
        "msgtype": "markdown",
        "markdown": {
            "title": f"协助代码Review",
            "text": f"""###  项目：[{kwargs["project_name"]}]({kwargs["project_url"]})\n\n"""
                    f"""#### [{kwargs["user_name"]}]({kwargs["user_url"]}) 创建了合并请求：\n\n"""
                    f"""#### {kwargs["origin_branch"]} --> {kwargs["target_branch"]} """
                    f"""[{kwargs["merge_title"]}]({kwargs["merge_title_url"]})\n\n"""
                    f"""#### 请{''.join(['@' + phone for phone in review_mobile if phone])} 协助代码review"""
        },
        "at": {
            "atMobiles": [phone for phone in review_mobile if phone],
            "isAtAll": False
        }
    }
    requests.post(url=MessageConf.ROBOT_URL, json=text, headers=headers)
